// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "TextInfos.generated.h"

/**
 * 
 */

UENUM(BlueprintType)
enum class ELayoutMode:uint8
{
	Horizontal,
	Vertical
};


USTRUCT(BlueprintType)
struct MOTIONSUBTITLES_API FTextLayoutInfo
{
	GENERATED_USTRUCT_BODY()

	FTextLayoutInfo(): Mode(ELayoutMode::Horizontal), KerningScale(1), AlignmentH(0), AlignmentV(0), Spacing(1),
	                   Enhance(1)
	{
	}

	UPROPERTY(EditAnywhere)
	ELayoutMode Mode;

	UPROPERTY(EditAnywhere)
	float KerningScale;

	UPROPERTY(EditAnywhere)
	int32 AlignmentH;

	UPROPERTY(EditAnywhere)
	int32 AlignmentV;

	UPROPERTY(EditAnywhere)
	float Spacing;

	UPROPERTY(EditAnywhere, meta = (ClampMin = 1, ClampMax = 2))
	float Enhance;
};


USTRUCT(BlueprintType)
struct MOTIONSUBTITLES_API FTextFontInfo
{
	GENERATED_USTRUCT_BODY()

	FTextFontInfo(): Bitmap(nullptr), Width(0), Height(0), AdvanceH(0), AdvanceV(0)
	                 , BearingH(0, 0), BearingV(0, 0)
	                 , BitmapTop(0), BitmapLeft(0), Enhance(1), FillingColor(FLinearColor::Black),
	                 OutlineColor(FLinearColor::White),
	                 ShadowColor(FLinearColor::Transparent)
	{
	}

	UPROPERTY(EditAnywhere)
	TObjectPtr<UTexture2DDynamic> Bitmap;

	// Font Metrics ////////////////////////////////////////
	UPROPERTY(EditAnywhere)
	int16 Width;

	UPROPERTY(EditAnywhere)
	int16 Height;

	UPROPERTY(EditAnywhere)
	float AdvanceH;

	UPROPERTY(EditAnywhere)
	float AdvanceV;

	UPROPERTY(EditAnywhere)
	FVector2D BearingH;

	UPROPERTY(EditAnywhere)
	FVector2D BearingV;

	UPROPERTY(EditAnywhere)
	float BitmapTop;

	UPROPERTY(EditAnywhere)
	float BitmapLeft;

	UPROPERTY(EditAnywhere)
	float Enhance;

	// Text Style ////////////////////////////////////////
	UPROPERTY(EditAnywhere)
	FLinearColor FillingColor;

	UPROPERTY(EditAnywhere)
	FLinearColor OutlineColor;

	UPROPERTY(EditAnywhere)
	FLinearColor ShadowColor;

	TWeakObjectPtr<UStaticMeshComponent> TextPlane;
};


USTRUCT(BlueprintType)
struct MOTIONSUBTITLES_API FTextStyle
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	int32 Index;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FString Font;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FLinearColor FillingColor;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FLinearColor OutlineColor;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool IsEnhance;
};

USTRUCT(BlueprintType)
struct MOTIONSUBTITLES_API FSubtitleContent
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FString Text;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TArray<FTextStyle> Styles;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float Offset;
};

USTRUCT(BlueprintType)
struct MOTIONSUBTITLES_API FSubtitleParams
{
	GENERATED_USTRUCT_BODY()
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TArray<FSubtitleContent> Contents;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float Duration;
};

USTRUCT(BlueprintType)
struct MOTIONSUBTITLES_API FSubtitleLineParams
{
	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	TArray<FTextFontInfo> FontInfos;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	float Offset;
};